<?php

namespace Database\Seeders;

use App\Models\Admin;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class AdminTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // 清空管理员表
        Admin::query()->truncate();

        // 创建管理员
        if ( Admin::query()->where('phone', '18715006008')->exists())
        {
            $this->command->line('超级管理员已存在');
            return;
        }
        $this->command->info('开始创建超级管理员...');
        Admin::query()->create([
            'name' => '超级管理员',
            'phone' => '18715006008',
            'email' => 'admin@ahimu.com',
            'password' => Hash::make('likaikai520'),
            'is_super' => 1,
            'avatar' => 'https://admin.ahimu.com/storage/avatar/J2Q6iPEKLmAjVgqxyZVvsMYJKAEysovcwyH2M5BS.jpg',
            'status' => 1,
        ]);
        $this->command->info('超级管理员创建成功！');
        $this->command->line('-----------------------');
        $this->command->line('账号:18715006008');
        $this->command->line('密码:likaikai520');
    }
}
